package backends

import (
	"log"

	"gitee.com/chenrh/finego/api"
	"gitee.com/chenrh/finego/backends/controllers/account"
	"gitee.com/chenrh/finego/backends/controllers/funds"
	"gitee.com/chenrh/finego/backends/controllers/home"
	"gitee.com/chenrh/finego/backends/controllers/pub"
	"gitee.com/chenrh/finego/backends/controllers/stocks"
	"gitee.com/chenrh/finego/backends/middleware"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
)

// Routers 全局大模块路由注册
func Routers(app *iris.Application) {

	log.Println("注册程序路由 开始..")

	// Serve a controller based on the root Router, "/".
	// app.Get("/", func(ctx iris.Context) { ctx.Redirect("/bbs") })

	root := mvc.New(app.Party("/"))
	root.Router.Use(middleware.PageIndexDataCheck)
	root.Handle(new(home.IndexController))
	root.Handle(new(home.NewsController))
	root.Handle(new(home.FilmController))

	api.RegisteRouters(app)
	pub.RegisteRouters(app)
	account.RegisteRouters(app)
	stocks.RegisteRouters(app)
	funds.RegisteRouters(app)

	log.Println("注册程序路由 完成..")
}
